import Vue from 'vue'
import Router from 'vue-router'
//1 同步加载js
// import Home from '@/pages/home/Home'
// import City from '@/pages/city/City'
// import Detail from '@/pages/detail/Detail'

Vue.use(Router)
export default new Router({
  routes: [
    {
      path: '/',
      name: 'Home',
      // 2 异步加载组件形式
      component: () => import('@/pages/home/Home')
    },
    {
      path: '/city',
      name: 'city',
      component: () => import('@/pages/city/City')
    },
    {
      //动态路由
      path: '/detail/:id',
      name: 'detail',
      component: () => import('@/pages/detail/Detail')
    },
  ],
  //解决滚动 导致其他页面也滚动了的问题
  scrollBehavior (to, from, savedPosition) {
    return {x: 0, y: 0}
  }
})
